const { defineConfig } = require('@vue/cli-service')

// Element-plus 自动导入组件
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')

module.exports = defineConfig({
  transpileDependencies: true,
  // 项目打包路径
  outputDir: './build',

  configureWebpack: {
    resolve: {
      alias: {
        //vue-cli中已经默认配置 @ 为 src路径
        components: '@/components',
      },
    },
    devtool: 'source-map',

    devServer: {
      proxy: {
        '^/api': {
          target: 'http://116.205.237.243:8080',
          // target: 'http://35m892w013.wicp.vip',
          // target: 'http://localhost:8081',
          pathRewrite: {
            '^/api': '',
          },
          changeOrigin: true,
          ws: true,
        },
      },
      allowedHosts: 'all',
    },
    plugins: [
      // Element-plus 自动导入组件
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  },
})
